/**
 * @file filter
 * @author liaoxuezhi@baidu.com
 */
/* eslint fecs-indent: [0, "space", 2, 2] */

import * as React from 'react';
import {
  Component,
  PropTypes
} from 'react';
import {render} from '../../renderer';
import {
  FormGroup
} from 'react-bootstrap';
import * as assign from 'object-assign';
import * as omit from 'lodash/omit';
import * as cx from 'classnames';
import {Enhance as FormItem} from '../form-item';

@FormItem({
  type:'form-button',
  attachForm: false,
  haveLabel: false,
  test: (path, config) => /(?:^|\/)(?:form-item)$/.test(path) && ~['button', 'submit', 'reset'].indexOf(config.type),
  validateSchema: 'http://amis.baidu.com/schemas/form.json#/definitions/button'
})
export default class FormButton extends Component {
  static propTypes = {
    className: PropTypes.string,
    type: PropTypes.string.isRequired,
    buttons: PropTypes.arrayOf(PropTypes.object)
  };

  render() {
    const {
      $path,
      className,
      formMode,
      formHorizontal,
      btnClassName
    } = this.props;

    return (
        render(`${$path}/action`, omit(this.props, ['$path', 'className', 'formMode', 'formHorizontal']), {
          className: btnClassName || className
        })
    );
  }
}
